package com.hspedu.poly.PolyObject_.detail_;

public class PolyDetail {
    public static void main(String[] args) {

        //向上转型：父类的引用指向了子类的对象
        //语法：父类类型
        Animal animal = new Cat();
        Object obj = new Cat();

        animal.eat();
        animal.wear();
        animal.sleep();
        animal.play();
        animal.show();

//        animal = new Dog;
//        Dog dog = animal;
        Cat cat = (Cat) animal;
        ((Cat) animal).catchMouse();

//        animal.catchMouse();//catchMouse()是Cat的特有方法,多态new的对象就不可以调用
    }
}
